#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<vector>
#include<string>



using namespace std;




int coinChange(vector<int>& coins, int amount) {
    int n = coins.size();
    int MAX = amount + 1;
    vector<int> dp(MAX, MAX);
    dp[0] = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 1; j <= amount; ++j) {
            if (coins[i] <= j && dp[j] != MAX)
                dp[j] = min(dp[j - coins[i]] + 1, dp[j]);
        }
    }
    return (dp[amount] == MAX ? -1 : dp[amount]);
}
int main() {
    vector<int> nums{ 1,2,5 };
    cout << coinChange(nums, 11);
}